window.__tnt||(window.__tnt={}),__tnt.comment||(__tnt.comment={}),__tnt.comment.post={clear:function(t){t.find("button,textarea").removeAttr("disabled"),t.find("button[type=submit]").button("reset"),t.find(".form-body").find("#comment-reply-preview").remove(),t.find("input[name=parent_uuid]").remove(),t.find("textarea[name=comment]").val(""),t.find(".alert").text("").hide()},prepare:function(t,n){if(n!=""){var e=$("#comment-"+n).clone();e.attr("id","comment-reply-preview"),e.find(".comment-options").remove(),e.find(".comment-footer").remove(),e.find(".replies").remove(),e.append("
"),t.find(".modal-body").prepend(e),t.append('')}},data:function(t){var n=t.find("input[name=app]").val(),e=t.find("input[name=id]").val(),a="",i="";return t.find("textarea[name=comment]").val()!=""&&(i=t.find("textarea[name=comment]").val()),t.find("input[name=parent_uuid]").length&&(a=t.find("input[name=parent_uuid]").val()),this.obj=new Object({id:e,app:n,comment:i,parent_uuid:a}),__tnt.user.authToken==null&&(t.find("input[name=alias]")&&(this.obj.alias=t.find("input[name=alias]").val()),t.find("input[name=tncms_captcha_id]")&&(this.obj.tncms_captcha_id=t.find("input[name=tncms_captcha_id]").val(),this.obj.tncms_captcha_response=t.find("input[name=tncms_captcha_response]").val()),t.find("textarea.g-recaptcha-response")&&(this.obj["g-recaptcha-response"]=t.find("textarea.g-recaptcha-response").val())),this.obj}},__tnt.comment.abuse={prepare:function(t,n){t.find(".modal-body").html("");var e=$("#comment-"+n).clone();e.attr("id","comment-report-preview"),e.find(".comment-options").remove(),e.find(".comment-footer").remove(),e.find(".replies").remove(),t.find(".modal-body").prepend(e),t.find("input[name=comment_id]").val(n)}},__tnt.comment.subscribe={prepare:function(t){try{window.localStorage&&localStorage.getItem("comment-subscribed-"+$("#asset-content").attr("data-asset-uuid"))&&__tnt.comment.subscribe.toggle()}catch{}},toggle:function(){var t=$("#commentSubscribe");if(t.length){var n=t.attr("action"),e=["/subscribe/","/unsubscribe/"];n.search(/\/subscribe\//)<0&&e.reverse(),t.attr("action",$("#commentSubscribe").attr("action").replace(e[0],e[1])),$("#commentSubscribeModal").find(".subscribe, .unsubscribe").toggle(),$("#comments").find(".watch span").toggle()}},set:function(){var t=$("#asset-content").attr("data-asset-uuid");try{window.localStorage&&localStorage.setItem("comment-subscribed-"+t,1)}catch{}},unset:function(){var t=$("#asset-content").attr("data-asset-uuid");try{window.localStorage&&localStorage.removeItem("comment-subscribed-"+t)}catch{}}},__tnt.comment.preview={append:function(t,n){t.length&&$.each(t,function(){__tnt.comment.preview.create(this.data,$("#commentPostModal").find(".template.success"),n)})},create:function(t,n,e){var a=e.hasClass("desc"),i=__tnt.comment.preview.sanitize(t.comment);if(t.parent_uuid!=""){var o=$("#comment-"+t.parent_uuid);o.find(".replies").length||o.append('
'),e=o.find(".replies").first()}var c=[{element:"img.avatar",attr:[{attr:"src",value:__tnt.user.avatar}]},{element:".comment-text",html:"

"+i+"

"}];__tnt.user.authToken!=null?c.push({element:".username",html:__tnt.user.screenName}):t.alias!=""&&c.push({element:".username",html:t.alias}),__tnt.template(n[0],e[0],a,c,function(m){__tnt.user.avatar!=null?$(m).find("div.avatar").remove():($(m).find("img.avatar").remove(),__tnt.user.authToken==null&&($(m).find("div.avatar").find("i").removeClass("fa-user").addClass("fa-user-secret"),$(m).find("div.avatar").find("[data-fa-i2svg]").attr("data-icon","user-secret")))}),__tnt.emoticon.handle($(".comment.preview .comment-text"))},sanitize:function(t){return typeof t=="string"&&(t=t.replace(//g,"")),t},store:function(t,n){var e=!1;try{if(window.sessionStorage){var a=new Array,i=new Date,o="",c=0;sessionStorage.getItem("comment-previews")!=null&&(a=JSON.parse(sessionStorage.getItem("comment-previews"))),o=i.getTime("u"),c=n.find('.comment[data-user="'+__tnt.user.screenName+'"]').length+n.find(".comment.preview").length,storedJSON={c,t:o,data:{comment:t.comment,parent_uuid:t.parent_uuid}},a.push(storedJSON);var m=$("#asset-content").attr("data-asset-uuid");try{sessionStorage.setItem("comment-previews-"+m,JSON.stringify(a)),e=!0}catch{}}}catch{}return e},fetch:function(){var t=$("#asset-content").attr("data-asset-uuid"),n="comment-previews-"+t,e=[],a="";try{window.sessionStorage&&(a=sessionStorage.getItem(n),a!=null&&(e=JSON.parse(a)))}catch{}return e},filter:function(t,n,e){var a=$("#asset-content").attr("data-asset-uuid"),i=n.find('.comment[data-user="'+__tnt.user.screenName+'"]'),o=i.length,c=new Date,m=[];if(typeof t<"u")var t=__tnt.comment.preview.fetch();if(typeof e>"u"&&(e=!1),t&&$.each(t,function(){var r=!1;this.c48e4&&(r=!0),r||m.push(this)}),e)try{sessionStorage.setItem("comment-previews-"+a,JSON.stringify(m))}catch{}return m},clear:function(){var t=$("#asset-content").attr("data-asset-uuid");try{sessionStorage.setItem("comment-previews-"+t,null)}catch{}}},__tnt.comment.pending={fetch:function(){var t=$("#comment-index").attr("data-asset-uuid"),n="comment-changes-"+t,e=[],a="";try{window.sessionStorage&&(a=sessionStorage.getItem(n),a!=null&&(e=JSON.parse(a)))}catch{}return e},process:function(t){t.length&&($(".warning-changes-pending").show(),$.each(t,function(){var n=$("#comment-"+this.data.comment_uuid);__tnt.comment.pending.mark(n)}))},mark:function(t){$(".warning-changes-pending").show(),t.find(".comment-body").append('Changes pending'),t.siblings(".contribute-tools").find("button.edit, button.approve, button.deny").prop("disabled",!0)},filter:function(t,n,e){var a=n.find(".comment"),i=a.length,o=n.data("asset-uuid"),c=new Date,m=[];if(typeof t<"u")var t=__tnt.comment.pending.fetch();if(typeof e>"u"&&(e=!1),$.each(t,function(){var r=!1;this.c48e4&&(r=!0),r||m.push(this)}),e)try{sessionStorage.setItem("comment-changes-"+o,JSON.stringify(m))}catch{}return m},has_value:function(t,n,e){return t.hasOwnProperty(n)&&t[n]===e},store:function(t,n){var e=!1,a=0;try{if(window.sessionStorage){var i=$("#comment-index").attr("data-asset-uuid"),o=new Array,c=new Date,m=c.getTime("u");sessionStorage.getItem("comment-changes-"+i)!=null&&(o=JSON.parse(sessionStorage.getItem("comment-changes-"+i))),a=n.find(".comment").length,storedJSON={c:a,t:m,data:{comment_uuid:t.comment_uuid}};for(var r=!1,s=0;s-1&&__tnt.user.screenName!=null&&(changes_pending=__tnt.comment.pending.filter(__tnt.comment.pending.fetch(),$("#comment-index"),!0),__tnt.comment.pending.process(changes_pending)),__tnt.emoticon.handle($(".comment .comment-text")),$("#commentPost, #commentEdit").find(".comment-emoticons-selector").on("click",function(t){t.preventDefault()}),__tnt.emoticon.handle($("#commentPost, #commentEdit").find(".emoticon-selector li a")),$("#commentPost, #commentEdit").find(".emoticon-selector li a").on("click",function(t){t.preventDefault();var n=$(this).attr("title"),e=$("#commentPost, #commentEdit").find("textarea");e.val(e.val()+n)}),$("a.comment-post").on("click",function(t){t.preventDefault(),__tnt.comment.post.clear($("#commentPost"));var n="";typeof $(this).attr("data-comment-id")<"u"&&(n=$(this).attr("data-comment-id")),__tnt.comment.post.prepare($("#commentPost"),n),$("#commentPostModal").modal({backdrop:"static",keyboard:!0,show:!0,remove:!1})}),$("#commentPost").on("submit",function(t){t.preventDefault(),$("#commentPostModal").find("button,textarea").attr("disabled",""),$("#commentPostModal").find("button[type=submit]").button("loading");var n=__tnt.comment.post.data($("#commentPost"));n.comment!=""&&$.ajax({type:"POST",url:$("#commentPost").attr("action"),data:n,success:function(e,a,i){if(e.success){__tnt.trackEvent({network:"Site",socialAction:"comment",url:window.location.href.split("?")[0]}),$("#commentPostModal").modal("hide"),$("#commentPostModal").find("button,textarea").removeAttr("disabled");var e=__tnt.comment.post.data($("#commentPost"));__tnt.comment.preview.store(e,$("#comment-area")),__tnt.comment.preview.create(e,$("#commentPost").find(".template.success"),$("#comment-area")),__tnt.comment.post.clear($("#commentPost"))}else{if(e.error.includes("update your profile")){var o='update your profile';e.error=e.error.replace("update your profile",o)}$("#commentPostModal").find(".alert.alert-info").html(e.error).show(),$("#commentPostModal").find("button,textarea").removeAttr("disabled"),$("#commentPostModal").find("button[type=submit]").button("reset"),$("#commentPostModal").modal("show")}__tnt.user.authToken==null&&($("#commentPostModal").find(".tncms-captcha-image").trigger("click"),$("#commentPostModal").find("input[name=tncms_captcha_response]").val(""))}})}),$("#comments").find(".report").on("click",function(t){t.preventDefault(),__tnt.comment.abuse.prepare($("#commentReport"),$(this).attr("data-comment-id")),$("#commentReportModal").modal({backdrop:"static",keyboard:!0,show:!0,remove:!1})}),$("#comments").find(".watch").on("click",function(t){t.preventDefault(),$("#commentSubscribeModal").modal({backdrop:"static",keyboard:!0,show:!0,remove:!1})}),__tnt.comment.subscribe.prepare(),jQuery("#commentSubscribe").bind("submit",function(t){t.preventDefault(),$("#commentSubscribeModal").modal("hide"),$.post($("#commentSubscribe").attr("action"),{id:$("#commentSubscribe").find("input[name=id]").val(),app:$("#commentSubscribe").find("input[name=app]").val()}).done(function(){try{window.localStorage&&(localStorage.getItem("comment-subscribed-"+$("#asset-content").attr("data-asset-uuid"))?__tnt.comment.subscribe.unset():__tnt.comment.subscribe.set())}catch{}__tnt.comment.subscribe.toggle()}).fail(function(){})}),$("#comments").find(".comment-options").on("click",function(t){t.preventDefault()}),$("#commentReport").submit(function(t){t.preventDefault(),$("#commentReportModal").find("button").attr("disabled",""),$("#commentReportModal").find("button[type=submit]").button("loading");var n=$(this),e=n.find("input[name=comment_id]").val();if(e!=""){var a={action:"comments:abuse",comment_id:e},i=Cookies.get("tncms_csrf_token");i&&(a.tncms_csrf_token=i),$.post(n.attr("action"),a).done(function(){$("#commentReportModal").modal("hide"),$("#commentReportModal").find("button[type=submit]").button("reset"),n.find("input[name=comment_id]").val(""),__tnt.template(document.getElementById("commentReportSuccessTemplate"),document.getElementById("comment-"+e),!0),$("#comment-"+e).find(".comment-heading").first().hide(),$("#comment-"+e).find(".comment-body").first().hide()}).fail(function(){__tnt.template(document.getElementById("commentReportErrorTemplate"),document.getElementById("#commentReport"),!0)})}}),$("button.comment-edit").on("click",function(t){var n=$(this).parents(".contribute-tools").siblings(".comment"),e=n.find(".comment-text p").html();$('#commentEditModal form textarea[name="content"]').val(e.replace(/
/g,` `)),$('#commentEditModal form input[name="commentid"]').val(n.data("comment-uuid")),$("#commentEditModal").modal({backdrop:"static",keyboard:!0,show:!0,remove:!1})}),$("#commentEdit").on("submit",function(t){t.preventDefault();var n=$("#commentEdit").serialize();$("#commentEditModal").find("button,textarea").prop("disabled",!0),$("#commentEditModal").find("button[type=submit]").button("loading"),n.content!=""&&$.ajax({type:"POST",url:$("#commentEdit").attr("action"),data:n,success:function(e,a,i){$("#commentEditModal").modal("hide"),$("#commentEditModal").find("button,textarea").prop("disabled",!1);var o=$("#commentEdit").find('input[name="commentid"]').val();__tnt.comment.pending.store({comment_uuid:o},$("#comment-index")),__tnt.comment.pending.mark($("#comment-"+o))}})}),$("#comment-index .contribute-tools .approve").click(function(t){var n=$(this),e=n.parents(".contribute-tools").siblings(".comment").data("comment-uuid"),a=$("#comment-index").data("asset-uuid"),i={submit:"approve",commentid:e,assetid:a},o=Cookies.get("tncms_csrf_token");o&&(i.tncms_csrf_token=o),$.ajax({type:"POST",url:location.href,data:i,success:function(c){__tnt.comment.pending.store({comment_uuid:e},$("#comment-index")),__tnt.comment.pending.mark($("#comment-"+e))}})}),$("#comment-index .contribute-tools a.deny").click(function(t){var n=$(this),e=n.parents(".contribute-tools").siblings(".comment").data("comment-uuid"),a=$("#comment-index").data("asset-uuid"),i=n.data("reason"),o={submit:"deny",commentid:e,assetid:a,reason:i},c=Cookies.get("tncms_csrf_token");c&&(o.tncms_csrf_token=c),$.ajax({type:"POST",url:location.href,data:o,success:function(m){__tnt.comment.pending.store({comment_uuid:e},$("#comment-index")),__tnt.comment.pending.mark($("#comment-"+e))}})})}); //# sourceMappingURL=tnt.comment.d9cead0184e727e733eeb8606e356fe3.js.map